<!DOCTYPE html>
<html lang="zxx">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="icon" href="images/favicon.png">
    <title>注册</title>

    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="css/materialize.css">
    <link rel="stylesheet" href="css/loaders.css">
    <link rel="stylesheet" href="css/lightbox.css">
    <link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
    <link rel="stylesheet" href="css/owl.carousel.min.css">
    <link rel="stylesheet" href="css/owl.theme.default.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/layer.css">
</head>
<body>
<!-- navbar -->
<div class="navbar">
    <div class="container">
        <div class="row">
            <div class="col s9">
                <div class="content-left" onclick="javascript:history.back(-1);">
                <i class="fa fa-chevron-left center"></i>
                	</div>
            </div>

        </div>
    </div>
</div>
<!-- end navbar -->

<!-- sidebar -->

<!-- end sidebar -->

<!-- sign up -->
<div class="sign-up segments-page">
    <div class="container">
        <div class="signup-contents">
            <div class="pages-title">
                <h3>会员注册</h3>
                <div class="line"></div>
            </div>
            <form id="form" onsubmit="return false" action="#" method="post">
                <input type="text" name="InviteCode" id="InviteCode" placeholder="推荐码">
                 <input type="text" id="mobile" name="usermobile" placeholder="手机号码">
                <input type="password" name="password" id="password" placeholder="密码">
                <input type="password" name="rpassword" id="rpassword" placeholder="确认密码">
				<input type="password" name="TradersPassword" id="TradersPassword" placeholder="交易密码">
               
                <div class="div user-input">
                    <input type="text" class="code" name="checkcode" placeholder="请输入手机验证码" style="width: 150px;"
                           maxlength="6">
                    <input type="button" class="obtain generate_code" value=" 获取验证码">
                </div>
                <button class="button" onclick="register();"><i class="fa fa-send"></i>注册</button>
            </form>

        </div>
    </div>
</div>
<!-- end sign up -->

<script src="js/jquery.min.js"></script>
<script src="js/materialize.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/main.js"></script>
<script src="js/layer.js"></script>
	<script src="js/jquery.md5.js"></script>
<script type="text/javascript">

    function register() {

        if ($("#InviteCode").val() == "") {
            layer.open({
                content: '推荐码不能为空!'
                , skin: 'msg'
                , time: 2 //2秒后自动关闭
            });
            return false;
        }
  if ($("#mobile").val() == "") {
            layer.open({
                content: '请输入手机号码!'
                , skin: 'msg'
                , time: 2 //2秒后自动关闭
            });
            return false;
        }
     

        if ($("#password").val() == "") {

            layer.open({
                content: '请输入密码!'
                , skin: 'msg'
                , time: 2 //2秒后自动关闭
            });
            return false;
        }

        if ($("#password").val() !== $("#rpassword").val()) {

            layer.open({
                content: '俩次密码不一致!'
                , skin: 'msg'
                , time: 2 //2秒后自动关闭
            });
            return false;
        }
		if ($("#TradersPassword").val() == "") {
		
		    layer.open({
		        content: '请输入交易密码!'
		        , skin: 'msg'
		        , time: 2 //2秒后自动关闭
		    });
		    return false;
		}
        var url = 'Member/register';
        var params = $('#form').serializeObject();
        var generate = api_request(url, 'POST', params);
        if (generate.code == 1) {
            layer.open({
                content: generate.data
                , skin: 'msg'
                , time: 2//2秒后自动关闭
                , end: function () {
                    location.href = generate.tourl;
                }
            });
        }


    }

    $(function () {
        $(".generate_code").click(function () {
            var disabled = $(".generate_code").attr("disabled");
            if (disabled) {
                return false;
            }

            if ($("#mobile").val() == "" || isNaN($("#mobile").val()) || $("#mobile").val().length != 11) {

                layer.open({
                    content: "请填写正确的手机号！"
                    , skin: 'msg'
                    , time: 2 //2秒后自动关闭
                });
                return false;
            }
            var params = $("#mobile").val();

            var url = 'Member/send?mobile=' + params;

            var generate = api_request(url, 'GET');

            if (generate.code == 1) {
                settime();
                layer.open({
                    content: generate.data
                    , skin: 'msg'
                    , time: 2 //2秒后自动关闭
                });
            }
        });
        var countdown = 180;
        var _generate_code = $(".generate_code");

        function settime() {
            if (countdown == 0) {
                _generate_code.attr("disabled", false);
                _generate_code.val("获取验证码");
                countdown = 180;
                return false;
            } else {
                $(".generate_code").attr("disabled", true);
                _generate_code.val("重新发送(" + countdown + ")");
                countdown--;
            }
            setTimeout(function () {
                settime();
            }, 1000);
        }
    })

</script>
</body>
</html>
